using CfgTable;
using IQIGame.Onigao.Framework;
using IQIGame.Onigao.Game;

namespace IQIGame.Onigao.GamePlay
{
    public class UIN_MallItemCellShort : UIBaseNode
    {
        #region Template Generate,don't modify
        protected class UIB_UIN_MallItemCellShort
        {
            #region ObjectBinding Generate
            public UnityEngine.GameObject nodeCommon { protected set; get; }
            public UnityEngine.GameObject numNode { protected set; get; }
            public IQIGame.Onigao.Framework.ExText textItemNum { protected set; get; }
            public virtual void InitBinding(ObjectBinding __binding)
            {
                __binding.TryGetVariableValue<UnityEngine.GameObject>("nodeCommon", out var __tbv0);
                this.nodeCommon = __tbv0;
                __binding.TryGetVariableValue<UnityEngine.GameObject>("numNode", out var __tbv1);
                this.numNode = __tbv1;
                __binding.TryGetVariableValue<IQIGame.Onigao.Framework.ExText>("textItemNum", out var __tbv2);
                this.textItemNum = __tbv2;
            }
            #endregion ObjectBinding Generate 
        }
        #endregion Template Generate,don't modify

        #region fields
        UIN_MallItemCellCommon mallItemCellCommon = null;

        CfgMallItem cfgMallItem = null;
        #endregion fields
        public int mallItemId { get; private set; }
        #region properties

        protected UIB_UIN_MallItemCellShort ui { get; set; }
        protected UIMsgDispatcher uiMsgDispatcher => this._msgDispatcher as UIMsgDispatcher;

        #endregion properties
        protected override void BeforeInit()
        {
            ui = new UIB_UIN_MallItemCellShort();
            ui.InitBinding(this.csObjBind);
        }

        protected override void OnInit()
        {
            this.isUpdate = true;
            this.mallItemCellCommon = this.InitChildNode<UIN_MallItemCellCommon>(this.ui.nodeCommon);
        }

        protected override void OnShow()
        {

        }

        protected override void OnHide()
        {

        }

        /// <summary>
        /// 添加UGUI侦听
        /// </summary>
        protected override void AddUGUIListener()
        {

        }

        /// <summary>
        /// 添加全局侦听（MsgDispatcher）
        /// </summary>
        protected override void AddMsgListeners()
        {

        }

        protected override void OnDispose()
        {
            this.mallItemCellCommon = null;

            this.cfgMallItem = null;
        }

        #region methonds

        public void Show(int nMallItemId)
        {
            this.mallItemId = nMallItemId;
            this.cfgMallItem = TableCenter.mallItem.Get(this.mallItemId);
            this.ui.textItemNum.text = string.Format(APIMall.ItemNumStyle, this.cfgMallItem.ItemNum[0]);
            this.mallItemCellCommon.Show(this.cfgMallItem);
        }

        #endregion methonds
    }
}
